/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dom4j;

import java.util.List;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;

/**
 *
 * @author xddai
 */
public class DomFilter {

    public static void main(String[] args) throws Exception {
        SAXReader xmlReader = new SAXReader();
        Document doc = xmlReader.read(DomFilter.class.getResourceAsStream("ttt.xml"));
        List<Node> node = doc.selectNodes("//sentence/args/arg[@type=\"Ny\"]");
        for (Node node1 : node) {
            System.out.println(node1.getText());
            Element text = node1.getParent().getParent().element("text");
            System.out.println(text.getText());
        }
    }
}
